/**
 * Created by Goodluck on 2017/3/20.
 */
function showNumberWithAnimation(i, j, randNumber) {

    var numberCell = $('#number-cell-' + i + "-" + j);
    numberCell.css('background-color', getNumberBackgroundColor(randNumber));
    numberCell.css('color', getNumberColor(randNumber));
    numberCell.text(randNumber);

    numberCell.animate({
        width: cellSideLength,
        height: cellSideLength,
        top: getPosTop(i, j),
        left: getPosLeft(i, j)
    }, 50);
    console.log(randx + "----" + randy + "--------" + randNumber);
}
function showMoveAnimation(fromX, fromY, toX, toY) {
    var numberCell = $('#number-cell-' + fromX + '-' + fromY);
    numberCell.animate({
        top: getPosTop(toX, toY),
        left: getPosLeft(toX, toY)
    }, 200);

}

function updateScore(score) {
    $('#score').text(score);
}

function two_char(n) {
    return n >= 10 ? n : "0" + n;
}
//TODO
function time_fun() {
    if (time_state===true) stop_time();
    time_state=true;
    var sec = 0;
        stop = setInterval(function () {
            sec++;
            var date = new Date(0, 0)
            date.setSeconds(sec);
            m = date.getMinutes(), s = date.getSeconds();
            document.getElementById("time").innerText = two_char(m) + ":" + two_char(s);
        }, 1000);


}
function stop_time() {
    if(time_state===false) return;
    clearInterval(stop);
}